﻿; (function (global) {

    'use strict';

    global.Strategies = global.Strategies || {};

    Strategies.NakedSingle = function NakedSingle() {
        this.type = 'filler';
    }

    Strategies.NakedSingle.prototype.perform = function (grid) {
        for (var i = 0; i < 9; i++) {
            for (var j = 0; j < 9; j++) {
                var cell = grid.cells[i][j];
                if (cell.candidates.count === 1) {
                    var value = cell.candidates.values[0];
                    cell.setValue(value);
                    SolvingHelper.removeDependingCandidates(cell, grid);
                    return cell;
                }
            }
        }

        return null;
    }
}(this));
